import { createApp } from 'vue'
import pinia from './stores'

import App from './App.vue'
import router from './routers'

const app = createApp(App)

import Icon from '@/components/Icon/index.vue'
import Pagination from '@/components/Pagination/index.vue'

import { checkPermission } from './utils/permission'

// 引入饿了么UI框架
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
//引入全部图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
// 注册ElementPlus
app.use(ElementPlus, {
  locale: zhCn,
})

// 引入全局样式
import '@/styles/index.scss'

app.use(pinia)
app.use(router)

// 全局组件挂载
app.component('Icon', Icon)
app.component('Pagination', Pagination)

app.directive('checkPermission', checkPermission)

app.mount('#app')
